<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>配送压力概览</title>
</head>
<body>
    <div th:fragment="content">
        <div class="container-fluid">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <h2 class="h3">配送压力概览</h2>
                <div>
                    <button class="btn btn-primary" onclick="refreshData()">
                        <i class="fas fa-sync-alt me-1"></i> 刷新数据
                    </button>
                </div>
            </div>

            <div class="alert alert-info mb-4">
                <i class="fas fa-info-circle me-2"></i>
                压力级别: 低压力 <span class="pressure-indicator pressure-low"></span> |
                中等压力 <span class="pressure-indicator pressure-medium"></span> |
                高压力 <span class="pressure-indicator pressure-high"></span>
            </div>

            <div class="row">
                <!-- 配送区域压力卡片 -->
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h5 class="card-title mb-0">区域配送压力</h5>
                        </div>
                        <div class="card-body">
                            <div class="table-container">
                                <table class="data-table">
                                    <thead>
                                        <tr>
                                            <th>区域名称</th>
                                            <th>压力等级</th>
                                            <th>配送员数量</th>
                                            <th>订单数量</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody id="regionTable">
                                        <tr th:each="region : ${regions}">
                                            <td th:text="${region.name}">区域名称</td>
                                            <td>
                                                <span th:if="${region.pressureLevel == 'low'}" class="badge badge-success">
                                                    <span class="pressure-indicator pressure-low"></span> 低压力
                                                </span>
                                                <span th:if="${region.pressureLevel == 'medium'}" class="badge badge-warning">
                                                    <span class="pressure-indicator pressure-medium"></span> 中等压力
                                                </span>
                                                <span th:if="${region.pressureLevel == 'high'}" class="badge badge-danger">
                                                    <span class="pressure-indicator pressure-high"></span> 高压力
                                                </span>
                                            </td>
                                            <td th:text="${region.courierCount}">10</td>
                                            <td th:text="${region.orderCount}">25</td>
                                            <td>
                                                <!-- 删除了"查看详情"按钮 -->
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <script>
            function refreshData() {
                location.reload();
            }

            // 在页面加载时标记当前菜单为活动状态
            document.addEventListener('DOMContentLoaded', function() {
                document.querySelectorAll('.sidebar-menu a').forEach(a => {
                    a.classList.remove('active');
                });
                document.getElementById('menu-delivery-pressure').classList.add('active');
            });
        </script>
    </div>
</body>
</html>
